<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>出库操作</title>

    <link rel="stylesheet" href="./css/self.css">
</head>

<body>
    <div class="sidebar">

        <ol class="sidebar-box">
            <li>
                <h1 style="color: aqua;">test</h1>
            </li>
            <li class=""><img src="" alt="" class="siderbar-img"><a href="./index.html" class="sidebar-text">首页</a></li>
            <li class=""><img src="" alt="" class="siderbar-img"><a href="./warehouse-query.html" class="sidebar-text">物资查询</a></li>
            <li class=""><img src="" alt="" class="siderbar-img"><a href="./warehouse-change.html" class="sidebar-text">物资更改</a></li>
            <li class=""><img src="" alt="" class="siderbar-img"><a href="./warehouse-add.html" class="sidebar-text">入库操作</a></li>
            <li class="sidebar-now"><img src="" alt="" class="siderbar-img"><a href="./warehouse-out.html" class="sidebar-text">出库操作</a></li>
            <li class=""><img src="" alt="" class="siderbar-img"><a href="./warehouse-queryadd.html" class="sidebar-text">入库表单查询</a></li>
            <li class=""><img src="" alt="" class="siderbar-img"><a href="./warehouse-queryout.html" class=" sidebar-text ">出库表单查询</a></li>
        </ol>

    </div>
    <div class="head-box">
        <h1>欢迎来到仓库管理系统</h1>
    </div>
    <div class="main-box">
        <h1 style="text-align: center;font-size: 50px;color: cornflowerblue;">你好，超级管理员</h1>
        <div style="height: auto;margin: 50px;border: 1px solid white;background-color: rgba(255, 255, 255, 0.493);">
            <h1>出库操作(更改时某个项目不更改则填*)</h1>
            <div class="message" style="display: flex;align-items: center;">
                <span>
                    <label for="input_woid" class="name_input">出库单号*</label>
                    <input type="text" name="input_woid" id="input_woid">
                </span>
                <span>
                    <label for="gid_input" class="name_input">商品id*</label>
                    <input type="text" name="gid_input" id="gid_input">
                </span>
                <!-- <span>
                    <label for="gname_input" class="name_input">商品名称</label>
                    <input type="text" name="gname_input" id="gname_input">
                </span>
                <span>
                    <label for="gtype_input" class="name_input">商品种类</label>
                    <input type="text" name="gtype_input" id="gtype_input">
                </span> -->
                <span>
                    <label for="gnumber_input" class="name_input">商品数量*</label>
                    <input type="number" name="gnumber_input" id="gnumber_input">
                </span>
                <span>
                    <label for="warehouse_id" class="name_input">仓库名称(store1)*</label>
                    <input type="text" name="warehouse_id" id="warehouse_id">
                </span>
                <span>
                    <label for="gprice_input" class="name_input">单价*</label>
                    <input type="text" name="gprice_input" id="gprice_input">
                </span>
                <span>
                    <label for="notes_input" class="name_input">备注</label>
                    <input type="text" name="notes_input" id="notes_input">
                </span>
                <span>
                    <button id="change_btn" onclick="btn_out_onclick()">出库</button>
                </span>
            </div>
            <div id="output">

            </div>
        </div>
</body>
<script type="text/javascript" src="./node_modules/jquery/dist/jquery.js" charset="UTF-8"></script>
<script>
    function btn_out_onclick() {
        var input_gid = document.getElementById('gid_input').value;
        // var input_gname = document.getElementById('gname_input').value;
        var input_woid = document.getElementById('input_woid').value;
        var input_warehouseid = document.getElementById('warehouse_id').value;
        var input_number = document.getElementById('gnumber_input').value;
        // var input_gtype = document.getElementById('gtype_input').value;
        var input_gnote = document.getElementById('notes_input').value;
        var input_gprice = document.getElementById('gprice_input').value;
        url0 = "http://localhost:80/index.php/Mysql/mysql_out_bygid/input_table_name/" + input_warehouseid + "/input_woid/" + input_woid + "/input_gid/" + input_gid + "/input_gnumber/" + input_number + "/input_gprice/" + input_gprice + "/input_gnote/" + input_gnote
        console.log(url0);
        $.ajax({
            url: url0,
            async: pageYOffset,
            contentType: "application/x-www-form-urlencoded",
            dataType: "json",
            success: function(data) {
                if (data == 'error3') {
                    alert("该出库单号已存在");
                    return 0;
                }
                if (data == 'error1') {
                    alert("未找到该id商品");
                    return 0;
                }
                if (data == 'error2') {
                    alert("该商品数量不足");
                    return 0;
                }

                alert("出库成功");
            },
            error: function(err) {
                // 请求失败， err是失败的内容
                print("请求失败");
            },
            complete: function(e) {
                // 不管成功还是失败都会调用这个函数
            }
        })
    }
</script>


</html>